<template>
  <div>
    <div id="slider" class="mui-slider">
      <div
        id="sliderSegmentedControl"
        class="mui-scroll-wrapper mui-slider-indicator mui-segmented-control mui-segmented-control-inverted"
      >
        <div class="mui-scroll">
          <span
            :class="['mui-control-item', item.id === 0 ? 'mui-active' : '']"
            v-for="item in piclistitle"
            :key="item.id"
            @click="rc(item.id)"
            >{{ item.title }}
          </span>
        </div>
      </div>
    </div>
    <ul>
      <router-link tag="li" v-for="item in piclist" :key="item.id" :to="'/home/picshare/picdetail/' + item.id">
        <img v-lazy="item.img_url" />
        <div class="info">
          <div class="info-title">{{ item.title }}</div>
          <div class="info-content">{{ item.zhaiyao }}</div>
        </div>
      </router-link>
    </ul>
  </div>
</template>
<script>
import { piclistitle, piclist } from "../../../static/api.js";
import mui from "../../../static/mui/js/mui.js";
export default {
  data() {
    return {
      piclistitle: [],
      piclist: [],
    };
  },
  methods: {
   async rc(id){
       this.piclist = await piclist(id);
    }
  },
  async created() {
    this.piclistitle = await piclistitle();
    this.piclistitle.unshift({ title: "全部", id: 0 });
    this.piclist = await piclist(0);
    console.log(this.piclist);
    console.log(this.piclistitle);
  },
  mounted() {
    mui(".mui-scroll-wrapper").scroll({
      deceleration: 0.0005, //flick 减速系数，系数越大，滚动速度越慢，滚动距离越小，默认值0.0006
    });
  },
};
</script>
<style lang="scss" scoped>
.mui-slider {
  touch-action: pan-x;
}

ul {
  list-style: none;
  margin: 0;
  padding: 0px 10px 50px;
  li {
    position: relative;
    background-color: #ccc;
    text-align: center;
    box-shadow: 0 0 7px gray;
    & + li {
      //排除第一个li，应用给其他的li
      margin-top: 10px;
    }
    img {
      // font-size: 0;
      width: 100%;
    }
    img[lazy="loading"] {
      width: 40px;
      height: 300px;
      margin: auto;
    }
    .info {
      position: absolute;
      bottom: 0;
      color: #fff;
      background-color: rgba(0, 0, 0, 0.5);
      min-height: 86px;
      .info-title {
        font-size: 14px;
      }
      .info-content {
        font-size: 13px;
        text-align: left;
        text-indent: 2em;
      }
    }
  }
}
</style>
